package com.web.controller;

import com.web.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description Email的Controller
 * @Author zhu_jinsheng[zhu_js@suixingpay.com]
 * @Date 2019/12/3 21:46
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/email", produces = "application/json; charset=utf-8")
public class EmailController {
    @Autowired
    private EmailService emailService;

    /**
     * @Description 邮件编辑页面
     * @Author zhu_jinsheng[zhu_js@suixingpay.com]
     * @return: java.lang.String
     * @Date 2019/12/8 14:05
     */
    @RequestMapping("/email_show")
    public String show() {
        return "pages/email/sendEmail";
    }

    /**
     * @Description 邮件发送功能
     * @Author zhu_jinsheng[zhu_js@suixingpay.com]
     * @Param request:  http请求
     * @return: java.lang.String
     * @Date 2019/12/8 14:05
     */
    @RequestMapping("/email_send")
    public String sendEmail(HttpServletRequest request) {
        String to = request.getParameter("to");
        String subject = request.getParameter("subject");
        String content = request.getParameter("content");
        emailService.sendEmail(to,subject,content);
        //重定向
        return "redirect:pages/email/sendEmail.html";
    }
}
